<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> - 打款处理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="__PUBLIC__/admin/favicon.ico">
    <link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/animate.css" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/js/plugins/fancybox/jquery.fancybox.css" rel="stylesheet">
    <link href="__PUBLIC__/admin/js/plugins/iCheck/custom.css" rel="stylesheet">

</head>
<style>
    #loading{
        /*height: 80px;*/
        width: 100%;
        position: absolute;
        /*top: 40%;*/
        margin-top: -35px;
        text-align: center;
    }
    .pagination a, .pagination span {
        background-color: #FFFFFF;
        border: 1px solid #DDDDDD;
        color: inherit;
        float: left;
        line-height: 1.42857;
        margin-left: -1px;
        padding: 4px 10px;
        position: relative;
        text-decoration: none;
    }

    .pagination a:focus, .pagination a:hover, .pagination span:focus, .pagination span:hover {
        z-index: 2;
        color: #23527c;
        background-color: #eee;
        border-color: #ddd;
    }
    .current{
        color: black;
        font-weight: 900;
    }
</style>
<div class="ibox-content" id="loading" style="background:none;z-index:-1">
    <div class="spiner-example">
        <div class="sk-spinner sk-spinner-three-bounce">
            <div class="sk-bounce1"></div>
            <div class="sk-bounce2"></div>
            <div class="sk-bounce3"></div>
        </div>
    </div>
</div>
<body class="gray-bg contacts" oncopy="copyval()">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">
                <div class="ibox-content">
                    <h2>打款处理</h2>
                    <div class="col-sm-12" style="margin-bottom: 1rem">
                        <form role="form" action="/Finance/remittance_list" method="get">
                            <div class="form-group">
                                <!--<label>商品code</label>-->
                                <input type="text" id="content" placeholder="" name="content" value="<{$search.content}>" class="form-control">
                            </div>

                            <div>
                                <!-- <div class="layui-inline"> -->
                                    <input style="height: 2.5rem;" class="laydate-icon" placeholder="起始时间" id="start" name="start" value="<{$search.start}>">
                                    <input style="height: 2.5rem;" class="laydate-icon" placeholder="截止时间" id="end" name="end" value="<{$search.end}>">                                    
                                <!-- </div> -->
                                <select class="form-control m-b" name="lender" id="lender" style="height:31px;margin-bottom: 0;padding-top: 3px;display: inline;width: 11%;">
                                    <!-- 订单状态0待审核1未还款2已还款3已逾期4被拒绝5待打款6坏账 -->
                                    <option value="">出借人</option>
                                    <volist name="lender_arr" id="vo">
                                    <option value="<{$vo.id}>" ><{$vo.name}></option>
                                    </volist>
                                </select>
                                <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit" id="search"><strong>搜索</strong>
                                </button>

                            </div>
                        </form>
                    </div>
                    <br>
                    <table class="table table-striped table-hover">
                        <tbody>
                        <tr>  
                            <!-- ID、客户姓名、客户手机号、放款金额、银行账号、开户行、申请时间、打款时间 -->
                            <th>ID</th>
                            <th>客户姓名</th>
                            <th>客户手机</th>
                            <th>借款金额</th>
                            <th>放款金额</th>
                            <th>银行账号</th>
                            <th>开户行</th>
                            <th>申请时间</th>
                            <th>打款时间</th>
                            <th>出借人</th>
                            <th class="client-status">操作</th>
                        </tr>
                        <volist name="list" id="v">
                        <tr>
                                <td><{$v.id}></td>
                                <td><{$v.username}></td>
                                <td><{$v.mobile}></td>
                                <td><{$v.loan_amount}></td>
                                <td><{$v.loan_amount1}></td>
                                <td><{$v.bankcard_id}></td>
                                <td><{$v.bank_name}></td>
                                <td><{$v.ctime}></td>
                                <td><{$v.get_time}></td>
                                <td><{$v.lender}></td>
                                <td class="client-status">
                                    <a class="btn btn-success btn-rounded y" onclick="add_remittance('<{$v.order_number}>','<{$v.id}>')"
                                       target="_blank" >打款</a>
                                    <a class="btn btn-primary btn-rounded y" onclick="add_reason('<{$v.order_number}>','<{$v.id}>')"
                                       target="_blank" >打款失败</a>
                                    <a class="btn btn-warning btn-rounded y" onclick="remittance('<{$v.order_number}>','<{$v.id}>')"
                                       target="_blank" >代扣打款</a>
                                    <a class="btn btn-info  btn-rounded" onclick="edit_bank('<{$v.bank_name}>','<{$v.bankcard_id}>','<{$v.bank_code}>','<{$v.bank_card_type}>','<{$v.bind_id}>')"
                                       target="_blank" >修改银行卡</a>
                                </td>
                        </tr>
                        </volist>
                            </tbody>
                    </table>
                    <ul class="pagination">
                        <if condition="$tol gt 10">
                        <{$fpage}>
                        </if>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="__PUBLIC__/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__PUBLIC__/admin/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="__PUBLIC__/admin/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__PUBLIC__/admin/js/plugins/layer/layer.min.js"></script>
<script src="__PUBLIC__/admin/js/layui/layui.js"></script>
<script src="__PUBLIC__/admin/js/layui/lay/modules/laydate.js"></script>

<!-- 自定义js -->
<script src="__PUBLIC__/admin/js/hAdmin.js?v=4.1.0"></script>

<script>

    //银行卡编辑
    function edit_bank(bank_name,bankcard_id,bank_code,bank_type,bind_id){

        console.log('1111',bank_code+bank_type);
        var bank='';
         $.post('__MODULE__/Finance/get_bank',{},function (data) {

             if(data.code='1001'){
                 bank=data.data;
//                 console.log('333',bank);

                 html='';
                 html+='<div class="modal-body" id="lists" style="height:100%">';
                 html+='<form class="form-horizontal">';
                 html+='<div class="form-group">';
                 html+='<label class="col-sm-3 control-label" >卡号：</label>';
                 html+='<div class="col-sm-8">';
                 html+='<input type="text" id="bankcard_id"  value="'+bankcard_id+'" placeholder="卡号" class="form-control">';
                 html+='</div>';
                 html+='</div>';

                 html+='<div class="form-group">';
                 html+='<label class="col-sm-3 control-label" >支行名：</label>';
                 html+='<div class="col-sm-8">';
                 html+='<input type="text" id="bank_name"  value="'+bank_name+'" placeholder="支行名" class="form-control">';
                 html+='</div>';
                 html+='</div>';
                 html+='<div class="form-group">';
                 html+='<label class="col-sm-3 control-label">银行：</label>';
                 html+='<div class="col-sm-8">';
                 html+='<select class="form-control m-b" name="bank_code" id="bank_code" style="height:3rem">';
                 for(var i=0;i<bank.length;i++){
                     html+='<option value="'+bank[i].bank_code+'"';
                     if(bank_code==bank[i].bank_code){
                         html+=' selected';
                     }
                     html+='>'+bank[i].bank_name+'</option>';
                 }
                 html+='</select>';
                 html+='</div>';
                 html+='</div>';


                 html+='<div class="form-group">';
                 html+='<label class="col-sm-3 control-label">卡类型：</label>';
                 html+='<div class="col-sm-8">';
                 html+='<select class="form-control m-b" name="bank_type" id="bank_type" style="height:3rem">';
//        for(var i=0;i<shopkeeper.length;i++){
                 html+='<option value="1"';
                 if(bank_type==1){
                     html+=' selected';
                 }
                 html+='>'+'借记卡'+'</option>';
                 html+='<option value="2"';
                 if(bank_type==2){
                     html+=' selected';
                 }
                 html+='>'+'信用卡'+'</option>';
//        }
                 html+='</select>';
                 html+='</div>';
                 html+='</div>';


                 html+='</form>';
                 html+='<div class="modal-footer" style="border:0">';
                 html+='<a href="javascript:void(0);" onclick="layer.closeAll()" type="button" class="btn btn-default" >关闭</a>';



//        if(n==1){
                 html+='<a href="javascript:void(0);" onclick="bind_bank_edit(\''+bind_id+'\');" type="button" class="btn btn-primary" >修改</a>';
//        }else{
//            html+='<a href="javascript:void(0);" onclick="applys(\''+chan_id+'\',0);" type="button" class="btn btn-primary" >添加</a>';
//        }
                 html+='</div>';
                 html+='</div>';


                 layer.open({
                     type: 1, //Page层类型
                     area: ['530px', '400px'],
                     title: '编辑渠道',
                     shade: 0.6, //遮罩透明度
                     maxmin: true, //允许全屏最小化
                     anim: 1, //0-6的动画形式，-1不开启
                     content: html
                 });


             }
         });


    }

    //确认修改

    function bind_bank_edit(bind_id) {

        layer.confirm('是否确定修改',function(){

            var bankcard_id=$('#bankcard_id').val();
            var bank_name=$('#bank_name').val();
            var bank_type=$('#bank_type').val();
            var bank_code=$('#bank_code').val();

            $.post('__MODULE__/Finance/bind_bank_edit',{bankcard_id:bankcard_id,bank_name:bank_name,bank_card_type:bank_type,jd_bank_code:bank_code,id:bind_id},function (data) {

                if(data.code='1001'){
                    window.location.reload();
                    layer.msg(data.info,{time:2000,icon:6});


                }else {
                    layer.msg(data.info,{time:2000,icon:5});
                }


            });




        });


        }


    function add_remittance(numbering,id) {        
            layer.open({
                title:'打款',
                type: 2,
                area: ['70%', '80%'],
                maxmin: true,
                offset:'100px',
                content: '__MODULE__/Finance/add_remittance.html?numbering='+numbering+'&id='+id,
                success: function(layero){
                    layero.find('.layui-layer-min').remove();
                }
            });

    }

    function add_reason(numbering,id) {        
            layer.open({
                title:'打款失败',
                type: 2,
                area: ['50%', '60%'],
                maxmin: true,
                offset:'100px',
                content: '__MODULE__/Finance/add_reason.html?numbering='+numbering+'&id='+id,
                success: function(layero){
                    layero.find('.layui-layer-min').remove();
                }
            });

    }


    function remittance(numbering,id){
            layer.confirm('是否确定打款',function(){                
                var index = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                $.post('__MODULE__/Finance/remittance',{numbering:numbering,id:id},function(data){                    
                    layer.closeAll();
                    // console.log(data);return;
                    if(data.status=='1001'){
                        layer.msg(data.result,{time:2000,icon:6});
                        window.location.reload();
                    }else if(data.status=='1002'){
                        layer.msg(data.info,{time:2000,icon:5});
                        // if(data.status=='0'){
                        //     layer.msg(data.info,{time:2000,icon:5});
                        // }else{
                        //     layer.msg(data.result,{time:2000,icon:5});
                        // }
                    }else{
                        layer.msg(data.result,{time:2000,icon:5});
                    }
                });
            });
        }

    $(document).ready(function () {
        $('.contact-box').each(function () {
            animationHover(this, 'pulse');
        });
    });

//        function set_black(vid,status){
//            layer.confirm('是否确定拉黑/解除黑名单',function(){
//                if(status==3){
//                    remove_black_user(vid,status);
//                }else{
//                    add_black_user(vid,status);
//                }
//                // $.post('/UserManage/set_black',{vid:vid,status:status},function(data){
//                //     // console.log(data);return
//                //     if(data.code=='1001'){
//                //         window.location.reload();
//                //     }else{
//                //         layer.msg(data.info,{time:2000,icon:5});
//                //         // if(data.status=='0'){
//                //         //     layer.msg(data.info,{time:2000,icon:5});
//                //         // }else{
//                //         //     layer.msg(data.result,{time:2000,icon:5});
//                //         // }
//                //     }
//                // });
//            });
//        }
//
//        function add_black_user(vid,status){
//            html='';
//            html+='<div class="modal-body" id="lists" style="height:100%">';
//            html+='<form class="form-horizontal">';
//            html+='<div class="form-group">';
//            html+='<label class="col-sm-3 control-label" >拉黑理由：</label>';
//            html+='<div class="col-sm-9">';
//            html+='<textarea style="height:10rem" type="text" id="reason" placeholder="拉黑理由,拉黑将影响用户的正常使用，请慎用。" class="form-control"></textarea><input type="hidden" value="'+vid+'" id="vid" /><input type="hidden" value="'+status+'" name="status" id="status" />';
//            html+='</div>';
//            html+='</div>';
//            html+='</form>';
//            html+='<div class="modal-footer" style="border:0">';
//            html+='<a href="javascript:void(0);" onclick="layer.closeAll()" type="button" class="btn btn-default" >关闭</a>';
//            html+='<a href="javascript:void(0);" onclick="set_black_user();" type="button" class="btn btn-primary" >确定</a>';
//            html+='</div>';
//            html+='</div>';
//            layer.open({
//                type: 1, //Page层类型
//                area: ['450px', '300px'],
//                title: '用户拉黑',
//                shade: 0.6, //遮罩透明度
//                maxmin: true, //允许全屏最小化
//                anim: 1, //0-6的动画形式，-1不开启
//                content: html
//            });
//        }
//
//        function remove_black_user(vid,status){
//            html='';
//            html+='<div class="modal-body" id="lists" style="height:100%">';
//            html+='<form class="form-horizontal">';
//            html+='<div class="form-group">';
//            html+='<label class="col-sm-3 control-label" >解除黑名单理由：</label>';
//            html+='<div class="col-sm-9">';
//            html+='<textarea style="height:10rem" type="text" id="reason" placeholder="解除黑名单理由。" class="form-control"></textarea><input type="hidden" value="'+vid+'" id="vid" /><input type="hidden" value="'+status+'" name="status" id="status" />';
//            html+='</div>';
//            html+='</div>';
//            html+='</form>';
//            html+='<div class="modal-footer" style="border:0">';
//            html+='<a href="javascript:void(0);" onclick="layer.closeAll()" type="button" class="btn btn-default" >关闭</a>';
//            html+='<a href="javascript:void(0);" onclick="set_black_user();" type="button" class="btn btn-primary" >确定</a>';
//            html+='</div>';
//            html+='</div>';
//            layer.open({
//                type: 1, //Page层类型
//                area: ['450px', '300px'],
//                title: '用户拉黑',
//                shade: 0.6, //遮罩透明度
//                maxmin: true, //允许全屏最小化
//                anim: 1, //0-6的动画形式，-1不开启
//                content: html
//            });
//        }


        function set_black_user(){
            var vid = $("#vid").val();
            console.log(vid);
            var status = $("input[name='status']").val();
            console.log(status);
            var reason = $("#reason").val();
            if(reason==''){
                layer.msg('理由不能为空',{time:2000,icon:5});
                return false;
            }
            $.post('/UserManage/set_black',{vid:vid,status:status,reason:reason},function(data){
                // console.log(data);return
                if(data.code=='1001'){
                    window.location.reload();
                }else{
                    layer.msg(data.info,{time:2000,icon:5});

                }
            });
        }




        function lock_user(vid,status){
            layer.confirm('是否确定锁定/解锁',function(){
                $.post('/UserManage/lock_user',{vid:vid,status:status},function(data){
                    if(data.code=='1001'){
                        window.location.reload();
                    }else{
                        layer.msg(data.info,{time:2000,icon:5});

                    }
                });
            });
        }



    layui.use('laydate', function(){
        var laydate = layui.laydate;
        var start = {
            choose:function(dates){
                end.min = dates; //开始日选好后，重置结束日的最小日期
                end.start = dates; //将结束日的初始值设定为开始日
            }
        };
        var end = {
            choose:function(dates){
                start.max = dates; //结束日选好后，重置开始日的最大日期

            }
        };

        document.getElementById('start').onclick = function(){
            start.elem = this;
            laydate(start);
        }
        document.getElementById('end').onclick = function(){
            end.elem = this;
            laydate(end);
        }
    });
    function copy(mobile){
        $.post('/Mypublic/copy', {mobile: mobile}, function (data) {
            if (data.code == '1001') {
            } else {
                console.log(data);
            }
        });
    }
    function copyval() {
        var content = window.getSelection().toString();
        $.post('/Mypublic/copy_all', {content:content}, function (data) {
            if (data.code == '1001') {
            } else {
                console.log(data);
            }
        });
    }
</script>
</body>
</html>